#!/bin/bash

#log path
export LOG_DIR=/opt/logs/100000002/epcc-209

cd `dirname $0`/..

printf "\n-------------------------------------------\n"
printf "stop server\n"

#process id
if [ -e application.pid ];then
  PID=`cat application.pid`
  kill $PID
  printf "kill $PID\n"
else
  printf "application.pid No such file\n"
  printf "process maybe shutdowned\n"
fi
#wait 50s
for i in 1 10; do
  if [ ! -e application.pid ];then
	printf "stop server success\n"
    printf "\n-------------------------------------------\n"
    break
  fi
  printf "sleep 5s\n"
  sleep 5		
done

#after 50s exec kill -9 
if [ -e application.pid ];then
  PID=`cat application.pid`
  kill -9 $PID
  printf "kill -9 $PID\n"
fi
printf "\n-------------------------------------------\n"
printf "exec command [tail -fn200 $LOG_DIR/epcc-209.log] to view shutdown log"
printf "\n-------------------------------------------\n"
